package edu.grupo4.appcomedores;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener {

    EditText editText1;
    EditText editText2;
    Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        editText1=(EditText)findViewById(R.id.editText1);
        editText2=(EditText)findViewById(R.id.editText2);
        button=(Button)findViewById(R.id.button);

        button.setOnClickListener(this);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public void onClick(View arg0){
        switch(arg0.getId()){
            case R.id.button:
                String user=editText1.getText().toString();
                String pswd=editText2.getText().toString();
                if(user.equals("Administrador")&&pswd.equals("123456")){
                    //Mostrar pantalla-Actividad
                    Intent int1= new Intent("edu.grupo4.appcomedores.Administrador");
                    startActivity(int1);
                }
                else{
                    if(user.equals("Dueno")&&pswd.equals("123456")){
                        //Mostrar pantalla-Actividad
                        Intent int1= new Intent("edu.grupo4.appcomedores.Dueno");
                        startActivity(int1);
                    }else{
                        //Toast Presenta un cuadro de dialogo
                        Toast t=Toast.makeText(this,"User o Password Incorrecto",Toast.LENGTH_SHORT);
                        t.show();
                    }
                }
                break;
        }
    }

}
